package com.example.managesystem.service.impl;

import com.example.managesystem.dto.FileDTO;
import com.example.managesystem.mapper.FileMapper;
import com.example.managesystem.mapper.ItemMapper;
import com.example.managesystem.service.FileService;
import com.example.managesystem.vo.ItemMaintextVO;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class FileServiceImpl implements FileService {
    @Autowired
    private FileMapper fileMapper;
    @Autowired
    private ItemMapper itemMapper;

    public void saveFile(FileDTO fileDTO) {
        //获取项目名称 并传入fileDTO
        Integer itemId = fileDTO.getItemId();

        String itemName = itemMapper.getItemName(itemId);
        fileDTO.setItemName(itemName);

        //设置文件的创建时间和结束时间
        fileDTO.setCreateTime(LocalDateTime.now());
        fileDTO.setOverTime(LocalDateTime.now().plusYears(1));

        fileMapper.saveFile(fileDTO);


    }
}
